package com.ang.juc.n5;

import lombok.AllArgsConstructor;
import lombok.Data;

public class TestBean {

    private volatile static User user;

    public static void main(String[] args) throws InterruptedException {
        user = new User(1, "ang");

        new Thread(()->{
            while (true){
                if(user.getId()==10){
                    break;
                }
            }

            System.out.println("终止");
        }).start();

        Thread.sleep(3000);
        user.setId(10);

    }

    @Data
    @AllArgsConstructor
    static class User{
        private Integer id;
        private String name;
    }
}
